package com.qf.feign;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class HeaderRequestInterceptor implements RequestInterceptor {

    //这个是浏览器访问User服务时对应的请求对象，包含浏览器发送过来的所有请求头信息
    @Autowired
    private HttpServletRequest request;

    @Override
    public void apply(RequestTemplate template) {
        String host = request.getHeader("Host");

        template.header("Host",host);
    }
}
